Capistrano.configuration(:must_exist).load do |c|
  namespace :xlr8 do
    task :default do
      prepare
      xlr8
    end # task default
    
    desc "Make sure that the Xlr8 configuration is happy"
    task :verify do
      puts "verify"
    end
    
    desc <<-DESC
      Prepare to xlr8. This is mainly here so that people can hook into it
      and perform tasks such as minification, glomming together multiple js or css
      files into one, etc. 

      Also see the rake task xlr8:prepare
    DESC
    task :prepare do
        # no-op. 
      puts "prepare"
    end

    task :xlr8 do
      # add in multi-stage support here (by passing the stage to rake)
      # but not sure how to test for it right now.
      run "cd #{release_path} && rake xlr8 RAILS_ENV=production RELEASE_NAME=#{release_name} APPLICATION=#{application}"
    end
  end # namespace xlr8

  after "deploy:finalize_update", "xlr8"
  before "deploy:update", "xlr8:verify"

end # Capistrano.configuration
